$(function(){
	
	$("#yzm_a").click(function(){
		var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
		var list = [];
		var a = Math.floor(Math.random()*36);
		var b = Math.floor(Math.random()*36);
		var c = Math.floor(Math.random()*36);
		var d = Math.floor(Math.random()*36);
		list = [arr[a],arr[b],arr[c],arr[d]];
		$("#yzm_pic").html(list);
	})	
	$("#yzm_pic").click(function(){
		var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
		var list = [];
		var a = Math.floor(Math.random()*36);
		var b = Math.floor(Math.random()*36);
		var c = Math.floor(Math.random()*36);
		var d = Math.floor(Math.random()*36);
		list = [arr[a],arr[b],arr[c],arr[d]];
		$(this).html(list);
	})	
	$("#user").focus(function(){
		$(this).css("border-color","#E0034F");
	})
	$("#user").blur(function(){
		$(this).css("border-color","#ccc");
	})
	
	$("#pass").focus(function(){
		$(this).css("border-color","#E0034F");
	})
	$("#pass").blur(function(){
		$(this).css("border-color","#ccc");
		var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
		var list = [];
		var a = Math.floor(Math.random()*36);
		var b = Math.floor(Math.random()*36);
		var c = Math.floor(Math.random()*36);
		var d = Math.floor(Math.random()*36);
		list = [arr[a],arr[b],arr[c],arr[d]];
		$("#yzm_pic").html(list);
	})
	$("#yzm").focus(function(){
		//$(this).attr("value","");
		$(this).css("border-color","#E0034F");
		
	})
	$("#yzm").blur(function(){
		$(this).css("border-color","#ccc");
	})
	
	$("#denglu").click(function(){
		var name = $("#user").val();
		var pwd = $("#pass").val();
		var yzm = $("#yzm").val();
		var yzm_pic = $("#yzm_pic").html();
		if(name == getCookie(name)&&pwd == getCookie(pwd)&&name!=""){	
			if(yzm == yzm_pic){
				setCookie("user",name,setCookieDate(7));
				setCookie("true", true,setCookieDate(7));
				window.location.href = "../index.html";					
			}else{
				$("#wrong").css({"display":"block","color":"red"}).html("验证码错误!");
			}
			
		}else{
			
			$("#wrong").css({"display":"block","color":"red"}).html("账号或密码错误!");
		}
	})
})